package com.chenjiagou.ordertickets.service.impl;

import com.chenjiagou.ordertickets.entity.Passenger;
import com.chenjiagou.ordertickets.dao.PassengerDao;
import com.chenjiagou.ordertickets.service.PassengerService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

/**
 * (Passenger)表服务实现类
 *
 * @author makejava
 * @since 2025-06-26 09:48:09
 */
@Service("passengerService")
public class PassengerServiceImpl implements PassengerService {
    @Resource
    private PassengerDao passengerDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Passenger queryById(Long id) {
        return this.passengerDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param passenger 实例对象
     * @return 实例对象
     */
    @Override
    public Passenger insert(Passenger passenger) {
        this.passengerDao.insert(passenger);
        return passenger;
    }

    /**
     * 修改数据
     *
     * @param passenger 实例对象
     * @return 实例对象
     */
    @Override
    public Passenger update(Passenger passenger) {
        this.passengerDao.update(passenger);
        return this.queryById(passenger.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.passengerDao.deleteById(id) > 0;
    }

    /**
     * 根据姓名，身份证,id查询
     * @param idNo
     * @return
     */
    @Override
    public boolean queryByGender(Long id,String fullName,String idNo) {
        return passengerDao.queryByGender(id,fullName,idNo)>0;
    }

    /**
     * 根据姓名，身份证,id更新乘车次数
     * @param fullName
     * @param idNo
     */
    @Override
    public void updateByCount(Long id,String fullName, String idNo) {
        passengerDao.update(id,fullName,idNo);
    }

    /**
     * 根据姓名，身份证,id查询乘客
     * @param fullName
     * @param idNo
     * @return
     */
    @Override
    public Passenger queryByIdNo(Long id,String fullName, String idNo) {
        return passengerDao.queryByIdNo(id,fullName,idNo);
    }
}
